#include "util_Util.h"
#include <stdlib.h>
#include <iostream>

#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
      
gsl_rng *gerador = gsl_rng_alloc(gsl_rng_mt19937);

JNIEXPORT void JNICALL Java_util_Util_diga
  (JNIEnv * env, jclass clas){
  std::cout << "Funcionando!";    
  return;      
}

JNIEXPORT jint JNICALL Java_util_Util_binomial
  (JNIEnv * env, jobject obj, jdouble p, jint n){
   
   return gsl_ran_binomial(gerador,p,n);       
}
  
JNIEXPORT jintArray JNICALL Java_util_Util_multinomial
  (JNIEnv * env, jobject obj, jint size, jint tam, jdoubleArray doubleArray, jintArray intArray){
   
   jdouble *p = env->GetDoubleArrayElements(doubleArray,0);
   jint *n = env->GetIntArrayElements(intArray, 0);    
   unsigned int* un = (unsigned int*) n; 
   
   gsl_ran_multinomial(gerador,size,tam,p,un);
   
   return (jintArray)un[0];
}

